
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String contextPath = request.getContextPath();
%>
<html>
<head>
    <title></title>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-easyui/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/cyUtil.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/cyEasyUi.js"></script>
<link rel="stylesheet"
      href="${pageContext.request.contextPath}/js/jquery-easyui/themes/default/easyui.css"
      type="text/css"/>
<link rel="stylesheet" href="${pageContext.request.contextPath}/js/jquery-easyui/themes/icon.css"
          type="text/css"/>
<%-- 引入扩展图标 --%>
<link rel="stylesheet" href="<%=contextPath%>/style/Icon.css" type="text/css">
<script type="text/javascript">
    var submitForm = function($dialog, $grid, $parent) {
        if ($('form').form('validate')) {
            var url = "${pageContext.request.contextPath}/resource/resource_save";

            $.post(url, serializeObject($('form')), function(result) {
                if (result.json.success) {
                    $grid.treegrid('reload');
                    $dialog.dialog('destroy');
                } else {
                    $parent.messager.alert('提示', result.json.msg, 'error');
                }
            }, 'json');
        }
    };

    var showIcons = function() {
        var dialog = parent.modalDialog({
            title : '浏览小图标',
            url : '${pageContext.request.contextPath}/style/icons.jsp',
            buttons : [ {
                text : '确定',
                handler : function() {
                    dialog.find('iframe').get(0).contentWindow.selectIcon(dialog, $('#icon'));
                }
            } ]
        });
    };

    $(function(){
        if($("input[name=id]").val().length > 0)
        {
            parent.$.messager.progress({
               text:"数据加载中...."
            });

            $.post("${pageContext.request.contextPath}/resource/resource_queryById",
                    {id:$("input[name=id]").val()},
                    function(result){
                        if(result.id != undefined){
                            $("form").form("load",{
                                "Tmenu.id" : result.id,
                                "Tmenu.name" : result.name,
                                "Tmenu.parameter" : result.parameter,
                                "Tmenu.pid" : result.pid,
                                "Tmenu.icon" : result.icon,
                                "Tmenu.seqID" : result.seqID,
                                "Tmenu.memo" : result.memo
                            });
                            $("#icon").attr("class",result.icon);
                        }
                        parent.$.messager.progress('close');
                    },"json");
        }
    })

</script>
</head>
<body>
    <form method="post" class="form">
        <fieldset>
            <legend>资源基本信息</legend>
            <table class="table" style="width: 100%;">
                <tr>
                    <th>编号</th>
                    <td><input name="Tmenu.id"/></td>
                    <th>资源名称</th>
                    <td><input name="Tmenu.name" class="easyui-validatebox" data-options="required:true" /></td>
                </tr>
                <tr>
                    <th>资源参数</th>
                    <td><input name="Tmenu.parameter" /></td>
                </tr>
                <tr>
                    <th>上级资源</th>
                    <td><select id="parent_id" name="Tmenu.pid" class="easyui-combotree" data-options="editable:false,idField:'id',textField:'text',parentField:'pid',url:'${pageContext.request.contextPath}/resource/resource_queryEazyUITree'" style="width: 155px;"></select><img class="iconImg ext-icon-cross" onclick="$('#parent_id').combotree('clear');"/></td>
                    <th>资源图标</th>
                    <td><input id="icon" name="Tmenu.icon" readonly="readonly" style="padding-left: 18px; width: 134px;" /><img class="iconImg ext-icon-zoom" onclick="showIcons();"/>&nbsp;<img class="iconImg ext-icon-cross" onclick="$('#icon').val('');$('#icon').attr('class','');"/></td>
                </tr>
                <tr>
                    <th>顺序</th>
                    <td><input name="Tmenu.seqID" class="easyui-numberspinner" data-options="required:true,min:0,max:100000,editable:true" style="width: 155px;" value="10" /></td>
                </tr>
                <tr>
                    <th>资源描述</th>
                    <td><textarea name="Tmenu.memo"></textarea></td>
                    <th></th>
                    <td></td>
                </tr>
            </table>
        </fieldset>
    </form>
</body>
</html>
